
<?php
session_start();
require_once '../models/Customer.php';
require_once '../models/Common.php';
require_once '../models/_check.php';
$msg="";

$customerID= $_SESSION["session_customer_id"];
$row	= Customer::getCustomerInfo($customerID);
if(isset($_POST['btn_submit'])){

	$f_name=$_POST["f_name"];
	$l_name=$_POST["l_name"];
	$gender=$_POST["gender"];
	$day=$_POST["ngay"];
	$month=$_POST["thang"];
	$year=$_POST["nam"];
	$email=$_POST["email"];
	$phone=$_POST["phone"];
	$address=$_POST["address"];
	$city=$_POST["city"];
	//check email trong sql da ton tai hay chua
			//Dang ky user moi
			$re=Customer::updateCustomer($customerID,$f_name,$l_name,$gender,$day,$month,$year,$email,$phone,$address,$city);
			if($re){
				//$page="update_customer.php?customerID=".$customerID;
				$_SESSION['msg']="Cập nhật thông tin thành công.";
				$page="success.php";
				Customer::redirectTo($page);
				
			}else{
			echo "	<script type='text/javascript'>
                               $(document).ready(function() {
								showNotification({
                                        type : 'error',
                                        message: 'Cập nhật thông tin thất bại.'
                                    });
							 })                            
                            </script>";}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Cập nhật thông tin tài khoản</title>
<?php include '_meta.php';?>
</head>
<body>
<form method="post">
	<div id="firstLine">
		<div id="top-bar">
		<?php include '_top_bar.php';?>
		</div>
	</div>
	<div id="container">
		<div id="header">
			<?php include '_head.php';?>
		</div>
		<?php include '_menu_head.php';?>
		<div id="center">
			<div id="menu-left">
				<?php include '../views/_menu_left_customer.php';?>
			</div>
			<div id="table">
					<table id="table-customer">
						<tr>
							<td><input  type="hidden" name="customerID" value="<?php echo $row["customerID"];?>" disabled="disable"></td>
						</tr>
						<tr>
							<th colspan="2">Thông tin cá nhân</th>
						</tr>
						<tr>
							<td>Họ:</td>
							<td><input type="text" name="f_name" class="btn_info" value="<?php echo $row['f_name'] ?>"></td>
						</tr>
						<tr>
							<td>Tên:</td>
							<td><input type="text" name="l_name" class="btn_info" value="<?php echo $row['l_name'] ?>"></td>
						</tr>
						<tr>
							<td>Giới tính:</td>
							<td><?php
								if($row['gender']=="Nam"){
								echo "<select name='gender' class='select_info'><option value='Nam'>Nam</option><option value='Nữ'>Nữ</option></select>";
								}else{
								echo "<select name='gender' class='select_info'><option value='Nữ'>Nữ</option><option value='Nam'>Nam</option></select>";
								}
								?>
							</td>
						</tr>
						<tr>
							<td><span>Ngày sinh:</span></td>
							<td><?php
								Common::dropBday();
								Common::dropBmonth();
								Common::dropByear();
								?>
							</td>
						</tr>
						<tr>
							<td>Email:</td>
							<td><input type="text" name="email" class="btn_info" value="<?php echo $row['email'] ?>"></td>
						</tr>
						<tr>
							<td>Phone:</td>
							<td><input type="text" name="phone" class="btn_info" value="<?php echo $row['phone'] ?>"></td>
						</tr>
						<tr>
							<td>Địa chỉ:</td>
							<td><input type="text" name="address" class="btn_info" value="<?php echo $row['address'] ?>"></td>
						</tr>
						<tr>
							<td>Thành phố:</td>
							<td><input type="text" name="city" class="btn_info" value="<?php echo $row['city'] ?>"></td>
						</tr>
						<tr>
							<td><input type="submit" name="btn_submit" class="btn_button_" value="Cập nhật"></td>
							<td><a href='customer.php'><input type="button" name="HuyBo" class="btn_button_" value="Huỷ bỏ"></a></td>
						</tr>
					</table>
			</div>
			<div id="menu-left">
				<?php include '_menu_left.php';?>
			</div>
		</div>
	</div>
	<div id="footer">
		<?php include '../views/_footer.php';?>
	</div>
</form>
</body>
</html>	